Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iconv-lite

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iconv-lite

Convert character encodings in pure javascript.

  • 0.4.24
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
94M
increased by2.27%
Maintainers
1
Weekly downloads
 
Created

What is iconv-lite?

The iconv-lite npm package provides utilities for converting character encodings in pure JavaScript. It supports many different encodings and can convert to and from Buffer objects without the need for a native C++ binding. This makes it a lightweight and portable solution for encoding conversion.

What are iconv-lite's main functionalities?

Encoding Conversion

Converts text from one character encoding to another. The example shows how to decode a buffer to a string and encode a string to a buffer using Windows-1251 encoding.

const iconv = require('iconv-lite');

// Convert from an encoded buffer to js string.
const str = iconv.decode(Buffer.from([0x63, 0x61, 0x66, 0xe9]), 'win1251');

// Convert from js string to an encoded buffer.
const buf = iconv.encode('Sample input text', 'win1251');

Streaming Conversion

Provides a streaming interface for encoding conversion. This example demonstrates how to create a read stream from a file and pipe it through iconv-lite's decode stream.

const iconv = require('iconv-lite');
const fs = require('fs');

// Decode stream (from a file, for example)
const readStream = fs.createReadStream('file.txt');
const decodeStream = iconv.decodeStream('win1251');

readStream.pipe(decodeStream);

decodeStream.on('data', function(str) {
  console.log(str); // converted text
});

Encoding Detection

Checks if a particular encoding is supported by iconv-lite. The example checks if UTF-8 encoding is supported.

const iconv = require('iconv-lite');

// Check if encoding is supported
const encodingSupported = iconv.encodingExists('utf-8');

console.log(encodingSupported); // true or false

Other packages similar to iconv-lite

Keywords

FAQs

Package last updated on 22 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc